package com.itheima.web;


import com.itheima.clients.UserClient;
import com.itheima.pojo.Order;
import com.itheima.pojo.User;
import com.itheima.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {

    //注入服务
    @Autowired
    private OrderService orderService;


    @Autowired
    private UserClient userClient;

    /**
     * 根据订单id查询订单信息
     *
     * @param ortderId
     * @return
     */
    @GetMapping("{orderId}")
    public Order queryOrderById(@PathVariable("orderId") Long ortderId) {
        Order order = orderService.findOrderById(ortderId);
        User user = userClient.queryUserById(order.getUserId());
        order.setUser(user);
        return order;
    }
}
